package com.vegetable.modules.entity.stock.to;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.vegetable.modules.entity.stock.Stock;
import com.vegetable.modules.entity.stock.StockFlow;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="库存流水", description="库存流水")
public class StockFlowDTO {

    @ApiModelProperty("主键id")
    @JsonSerialize(using = ToStringSerializer.class)
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "商品ID")
    private Long commodityId;

    @ApiModelProperty(value = "商品名称")
    private String commodityName;

    @ApiModelProperty(value = "商品编码")
    private String commonCode;

    @ApiModelProperty(value = "单据编号")
    private String orderNo;

    @ApiModelProperty(value = "单据类型：0 代办交货入库 1 物流园采购入库 2 散货采购入库 4 销售退货入库 5 盘盈入库 6 其他入库 7 销售出库 8 盘损出库 9 采购退货出库 10 调拨出库 11 调拨入库 12 代销出库 13 其他出库")
    private Integer orderType;

    @ApiModelProperty(value = "调整数量")
    private BigDecimal num;

    @ApiModelProperty(value = "调整重量")
    private BigDecimal weight;

    @ApiModelProperty(value = "调整数量总和")
    @TableField(exist = false)
    private BigDecimal totalNum;

    @ApiModelProperty(value = "规格ID")
    private Long specsId;

    @ApiModelProperty(value = "规格名称")
    private String specsName;

    @ApiModelProperty(value = "标签")
    private String tags;

    @ApiModelProperty(value = "标准")
    private BigDecimal standard;

    @ApiModelProperty(value = "成本")
    private BigDecimal cost;

    @ApiModelProperty(value = "剩余库存")
    private BigDecimal surplusStock;

    @ApiModelProperty(value = "仓库ID")
    private Integer warehouseId;

    @ApiModelProperty(value = "仓库名称")
    private String warehouseName;

    @ApiModelProperty(value = "订单时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd")
    private Date orderTime;

    @ApiModelProperty(value = "实际发生时间")
//    @DateTimeFormat(pattern = "yyyy-MM-dd")
//    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd")
    private Date createTime;

    @ApiModelProperty(value = "库存批次编码")
    private String stockBatchNo;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "入库数量")
    private BigDecimal inNumber = BigDecimal.ZERO;

    @ApiModelProperty(value = "入库流水")
    private List<StockFlow> inStockFlows;

    @ApiModelProperty(value = "入库成本")
    private BigDecimal inCost;

    @ApiModelProperty(value = "出库数量")
    private BigDecimal outNumber = BigDecimal.ZERO;

    @ApiModelProperty(value = "出库流水")
    private List<StockFlow> outStockFlows;

    @ApiModelProperty(value = "出库成本")
    private BigDecimal outCost;

    @ApiModelProperty(value = "结余数量")
    private BigDecimal initNumber;

    @ApiModelProperty(value = "结余数量")
    private BigDecimal balanceNumber;

    @ApiModelProperty(value = "结余数量")
    private List<Stock> initStockList;

    @ApiModelProperty(value = "结余数量")
    private List<Stock> balanceStockList;

    @ApiModelProperty(value = "结余数量")
    private List<Stock> intStockList;

    @ApiModelProperty(value = "结余数量")
    private List<Stock> outStockList;

    @ApiModelProperty(value = "结余成本")
    private BigDecimal balanceCost;

    @ApiModelProperty(value = "关联方")
    private String agentName;

    @ApiModelProperty(value = "关联方Id")
    private Long agentId;

    @ApiModelProperty(value = "产品流向")
    private String targetName;

    @ApiModelProperty(value = "结余成本")
    private String workName;

    @ApiModelProperty(value = "库存id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long stockId;

    private List<StockFlow> tempFlow;

    @ApiModelProperty(value = "销售订单明细id")
    private Long detailId;
}
